<?

include_once("codelibrary/inc/variables.php");

include_once("session.php");



function query($query) {

	$res = mysql_query($query) or die("Query Execution Error:<br>".mysql_error()."<br>$query");

	return $res;

}

$query = "select pk.*,ad.dateadded from packages as pk

		  left join administrator_info as ad on ad.package_id=pk.package_id

		  where ad.administrator_id='".$_SESSION['administrator_id']."'";



$res = query($query);



$currentpackage = mysql_fetch_object($res); 



if($currentpackage->access_days!=0) {

	$access_days = $currentpackage->access_days;

} else {

	$access_days = "Unlimited";	

}



if($currentpackage->staff_limit!=0) {

	$staff_limit = $currentpackage->staff_limit;

} else {

	$staff_limit = "Unlimited";	

}



$dateadded = date("d M,y H:i",strtotime($currentpackage->dateadded));



$total_days = ($_SESSION['access_days']-1);

$currentdate = mktime();

$noofdays = ($currentdate-strtotime($currentpackage->dateadded))/86400;

$days_remaining = floor($total_days - $noofdays) + 1;





$query = "select * from packages where package_id!=1 and enabled=1";

$packages = query($query);



?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html dir="LTR" lang="en">



<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<title>Online Appointment</title>



<base >

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<title>Staff Management</title>
<style type="text/css">
<!--
.style1 {
	font-size: 14px;
	font-weight: bold;
}
-->
</style>
</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<script>

var package_id = Array();

var item_name = Array();

var item_value = Array();



	function validate(frm) {

		var flag = true;

		

		if(frm.item_number.value=="") {

			flag = false;

		} else if(frm.item_name.value=="") {

			flag =  false;		

		} else if(frm.amount.value=="") {

			flag =  false;		

		}

		if(!flag) {

			alert("Please select a package");

		}

		

		return flag;

	}

	

	function setValue(id) {

		document.getElementById("item_number").value = id;

		document.getElementById("item_name").value = item_name[id];

		document.getElementById("amount").value = item_value[id];

	}



</script>



<table cellpadding="0" cellspacing="0" border="0"><tr>

  <td style="background:url(images/top.gif) repeat-x top; ">

<table cellpadding="0" cellspacing="0" border="0" style="width:764px" align="center"> 

	<tr>

		<td>

			<table cellpadding="0" cellspacing="0" border="0" style="height:57">

				<tr>

					<td height="57">

<? //html_header(); ?>					<form name="papalfrm" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="return validate(this)">
</form>
<span class="style1"><a href="make-appointment.php">Back</a></span></td>

				</tr>

			</table>





		</td>

	</tr>

	<tr>

		<td>











<table border="0" width="105%" cellspacing="0" cellpadding="0">

  <tr>

    <td valign="top" class="col_left">



<table border="0"cellspacing="0" cellpadding="0" class="box_width_left">

	<tr><td width="100%">

		<table border="0" cellspacing="0" cellpadding="0">

<tr><td>



<table border="0" width="100%" cellspacing="0" cellpadding="0" class="">

  <tr>

    <td>

    <table border="0" width="100%" cellspacing="0" cellpadding="0"  class="" height="91">

  <tr>

    <td align="center" height="91">

    <img border="0" src="images/logo.jpg" width="208" height="86"></td>

  </tr>

</table>

</td>

  </tr>

</table>

</td></tr>





          <tr>

            <td>

<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="box_header_txt" height="48">

  <tr>

    <td style="background-image: url(images/1_bg2-2.gif)" height="1">

      <p style="margin-top: 16"> </td>

  </tr>

</table>

<table border="0" width="100%" cellspacing="0" cellpadding="0"   style="border-bottom:12px solid #ffffff;">

  <tr>

    <td>

    <table border="0" width="100%" cellspacing="0" cellpadding="0"  style="margin-bottom:0px;background:#7C7C7C url(images/1_line.gif) no-repeat left bottom;" >

  <tr>

    <td  style="padding:3px 16px 8px 25px;">

      <table width="100%" border="0">

        <tr>

          <td>&nbsp;</td>

          <td>&nbsp;</td>

        </tr>

        <tr>

          <td>&nbsp;</td>

          <td>&nbsp;</td>

        </tr>

      </table>

    </td>

  </tr>

</table>

</td>

  </tr>

</table>

            </td>

          </tr>





          <tr>

            <td class="">&nbsp;

</td>

          </tr>



		</table>

	</td>

	<td><img src="images/spacer.gif" border="0" alt="" width="15" height="1"></td></tr>

</table>



    </td>



    <td width="100%" valign="top">

<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="cont_header_txt">

  <tr>

    <td>

			<table border="0" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA" class="cont_header_txt">

				<tr>

					<td><img src="images/1_q1.gif" border="0" alt="" width="45" height="39"></td>

					<td style="width:100%">Change package </td>

					<td><img src="images/1_q2.gif" border="0" alt="" width="10" height="39"></td>

				</tr>

			</table>										 

			</td>

  </tr>

</table>





						

						<table cellpadding="0" cellspacing="0" border="0" style="border:0px solid #DEDEDE; border-width:0px 1px 0px 1px;">

                          <tr>

                            <td style="background:#ffffff;border:0px solid #ffffff; border-width:18px 5px 10px 5px;"><!-- new_products //-->

                               

								<table border="0" width="" cellspacing="5" cellpadding="3" class="box_width_cont product">

                            <form name="frm" action="" method="post">

						          <tr>

                                    <td colspan="2">Please select a package from the list below and click paypal link to pay for that package. </td>

                                  </tr>

                                  <tr>

                                    <td colspan="2">&nbsp;</td>

                                  </tr>

                                  <tr>

                                    <td colspan="2"><strong>Current Package</strong> </td>

                                  </tr>

                                  <tr>

                                    <td width="25%">Package Name</td>

                                    <td width="75%">: <?=$currentpackage->package_name?> ( <?=$access_days?> Days, <?=$staff_limit?> Staff Members )</td>

                                  </tr>

                                  <tr>

                                    <td>Added On</td>

                                    <td>: <?=$dateadded?></td>

                                  </tr>

                                  <tr>

                                    <td>Days Left</td>

                                    <td>: <?=$days_remaining?> / <?=$total_days?></td>

                                  </tr>

                                  <tr>

                                    <td>&nbsp;</td>

                                    <td>&nbsp;</td>

                                  </tr>

                                  <tr>

                                    <td><strong>Update Package</strong> </td>

                                    <td>&nbsp;</td>

                                  </tr>

								  <?

								  while($package= mysql_fetch_object($packages))

								  {

								  

								  if($package->access_days!=0) {

										$paccess_days = $package->access_days;

									} else {

										$paccess_days = "Unlimited";	

									}

									

									if($package->staff_limit!=0) {

										$pstaff_limit = $package->staff_limit;

									} else {

										$pstaff_limit = "Unlimited";	

									}

									$price = $package->price;

								  $item_name = $package->package_name." ( ".$paccess_days." Days, ".$pstaff_limit." Staff Members ) $".$package->price;;

								  ?>

                                  <tr>

                                    <td align="right"><input name="package_id" type="radio" value="<?=$package->package_id?>" onClick="setValue(this.value)"></td>

                                    <td valign="middle">: <?=$item_name?>

									<script>

									package_id[<?=$package->package_id?>] = "<?=$package->package_id?>";

									item_name[<?=$package->package_id?>] = "<?=$item_name?>";

									item_value[<?=$package->package_id?>] = "<?=$package->price?>";

									</script>

									</td>

                                  </tr>

								 <? } ?>

	</form>

                                  <tr>

                                    <td>&nbsp;</td>

                                    <td>                                  

                                  </tr>

                                  <tr>

								  

                                    <td>&nbsp;</td>

                                  <td>	  	  <form name="papalfrm" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="return validate(this)">

								<input type="hidden" name="notify_url" value="http://www.bridge-ams.com/payment/ipn_process.php">

								<input type="hidden" name="custom" value="<?=$_SESSION['administrator_id'];?>">

			<input type="hidden" name="cmd" value="_xclick">

			<input type="hidden" name="business" value="support@bridge-all.com">

			<input type="hidden" name="item_name" id="item_name" value="">

			<input type="hidden" name="item_number" id="item_number" value="">

			<input type="hidden" name="amount" id="amount" value="">

			<input type="hidden" name="no_shipping" value="0">

			<input type="hidden" name="no_note" value="1">

			<input type="hidden" name="return" value="http://www.bridge-ams.com/payment-thanks.php">

			<input type="hidden" name="currency_code" value="USD">

			<input type="hidden" name="lc" value="US">

			<input type="hidden" name="bn" value="PP-BuyNowBF">

			<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">

			<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
                                  </form>

								    </td>   
                                  </tr>

                                </table>

		

                              </table>

			

						



							  </td>

                          </tr>

                        </table>

			

						<table cellpadding="0" cellspacing="0" border="0">

							<tr>

								<td><img src="images/1_q4.gif" border="0" alt="" width="10" height="10"></td>

								<td style="width:100%; background-image:url(images/1_li1.gif)"></td>

								<td><img src="images/1_q3.gif" border="0" alt="" width="10" height="10"></td>

							</tr>

						</table>

						





		

		

		</td>



    <td class="col_right">



<table border="0"cellspacing="0" cellpadding="0" class="box_width_right">

	<tr><td></td>

		<td width="100%">

			<table border="0" cellspacing="0" cellpadding="0">

				<tr><td></td></tr>

			</table>

		</td>

	</tr>

</table>





    </td>

  </tr>

</table>







		</td>

	</tr>

	<tr>

		<td>

			<table cellpadding="0" cellspacing="0" border="0" style="height:98px; background-image:url(images/bot.gif)">

				<tr>

					<td>

						<table cellpadding="0" cellspacing="0" border="0" class="footer">

							<tr>									

								<td height="77"><img src="images/spacer.gif" border="0" alt="" width="25" height="1"></td>				

								<td style="width:207px"><br style="line-height:49px"><img src="images/p1.gif" border="0" alt="" width="145" height="24"><br></td>

							  <td style="width:532px">&nbsp;</td>

							</tr>

						</table>

					</td>

				</tr>

			</table>

		</td>

	</tr>

</table></td></tr></table>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

  <tr>

    <td align="center"></td>

  </tr>

</table>

</body>



</html>